package com.iqiyi.pps.epg.core.service.carousel;

import com.iqiyi.pps.epg.core.model.carousel.AutoCarouselEpisodeLibrary;

/**
 * Created by Lemuel on 2016/6/29.
 */
public class AutoProgramNode {
    private AutoProgramNode nextNode;
    private boolean firstSign = false;
    private boolean endSign = false;
    private AutoCarouselEpisodeLibrary program;

    public AutoProgramNode(AutoCarouselEpisodeLibrary program) {
        this.program = program;
    }

    public AutoProgramNode getNextNode() {
        return nextNode;
    }

    public void setNextNode(AutoProgramNode nextNode) {
        this.nextNode = nextNode;
    }

    public boolean isFirstSign() {
        return firstSign;
    }

    public void setFirstSign(boolean firstSign) {
        this.firstSign = firstSign;
    }

    public boolean isEndSign() {
        return endSign;
    }

    public void setEndSign(boolean endSign) {
        this.endSign = endSign;
    }

    public AutoCarouselEpisodeLibrary getProgram() {
        return program;
    }

    public void setProgram(AutoCarouselEpisodeLibrary program) {
        this.program = program;
    }

    public AutoProgramNode getCurrentUse(long id) {
        AutoProgramNode temp = this;
        do {
            if (temp.getProgram().getId() == id) {
                return temp;
            } else {
                temp = temp.getNextNode();
            }
        } while (!temp.equals(this));
        return null;
    }

    public AutoProgramNode getFirstNode() {
        AutoProgramNode temp = this;
        do {
            if (temp.isFirstSign()) {
                return temp;
            } else {
                temp = temp.getNextNode();
            }
        } while (!temp.equals(this));
        return null;
    }

}
